package com.atguigu.service.impl.product;

import com.atguigu.entity.product.ProductSpec;
import com.atguigu.mapper.product.ProductSpecMapper;
import com.atguigu.service.product.ProductSpecService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ProductSpecServiceImpl implements ProductSpecService {
    @Autowired
    private ProductSpecMapper productSpecMapper;

    @Override
    public List<ProductSpec> findAll() {
        List<ProductSpec> productSpecList = productSpecMapper.findAll();
        return productSpecList;
    }

    @Override
    public PageInfo<ProductSpec> findByPage(Integer current, Integer limit) {
        PageHelper.startPage(current, limit);
        List<ProductSpec> productSpecList = productSpecMapper.findAll();
        return new PageInfo<>(productSpecList);
    }

    @Override
    public void save(ProductSpec productSpec) {
        productSpecMapper.save(productSpec);
    }

    @Override
    public void updateById(ProductSpec productSpec) {
        productSpecMapper.updateById(productSpec);
    }

    @Override
    public void deleteById(Long id) {
        productSpecMapper.remove(id);
    }
}
